<?php

namespace app\service\impl;

use app\repository\DishRepository;
use app\service\DishService;
use app\support\ListContainer;
use DI\Attribute\Inject;

class DishServiceImpl implements DishService
{
    #[Inject]
    public DishRepository $dishRepository;

    public function listOf(array $dishPageQueryDTO): ListContainer
    {
        return $this->dishRepository->listOf($dishPageQueryDTO);
    }

    public function getDishById( $id)
    {
        return $this->dishRepository->getDishById($id);
    }

    public function saveWithFlavors(array $params)
    {
        return $this->dishRepository->saveWithFlavors($params);
    }

    public function deleteDishsWithFlavors(array $params)
    {
        $ids = $params['ids'] ?? [];
        $ids = explode(",", $ids);

        $this->dishRepository->deleteDishsWithFlavors($ids);
    }

    public function startOrStop($status, $id)
    {
        $this->dishRepository->startOrStop($status, $id);
    }

    public function update(array $dish)
    {
        $this->dishRepository->update($dish);
    }

    public function list(array $params): array
    {
        return $this->dishRepository->list($params);
    }
}